package cn.nbt.busManage.model.dto;

import cn.nbt.busManage.model.entity.Menu;
import cn.nbt.busManage.model.entity.Role;
import cn.nbt.busManage.model.vo.RoleVo;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class RoleDto {
    private Integer id;
    private String roleName;
    private Integer status;
    private List<MenuDto> menus;
    public RoleDto(Role role){
        this.id = role.getId();
        this.roleName = role.getRoleName();
        this.status = role.getStatus();
        ArrayList<MenuDto> menuDtos = new ArrayList<>();
        for (Menu menu : role.getMenus()){
            MenuDto menuDto = new MenuDto(menu);
            menuDtos.add(menuDto);
        }
        this.menus = menuDtos;
    }
    public RoleDto(RoleVo roleVo){
        this.id = roleVo.getId();
        this.roleName = roleVo.getRoleName();
        this.status = roleVo.getStatus();

    }
}
